<?php
ifi!perms_check('admin', 'panel'))
{
	redirect('index.php?module=error&error=auth_error');
	exit;
}

if($d=is_module_installed($_GET['action'])) {
	if($d->function==1 or $d->function=='external') include_once('includes/functions/'.$_GET['action'].'.php');
	if($d->admin==0) { redirect('index.php?module=error&error=module_error'); exit; }
}
else $_GET['action']='';

if(!$_GET['action'] or !file_exists('admin/'.$_GET['action'].'.php') or ereg('\.\.', $_GET['action']))
$_GET['action']='main';

//generatin $content
include("admin/$_GET[action].php");
//

//generating menus (what, template)
$menu_left=menu('admin', 'left');
$menu_top=menu('top', 'top');
//

//site_generation_time
$GLOBALS['time_end'] = microtime(1);
$site_generation_time=abs(round($GLOBALS['time_end']-$GLOBALS['time_start'], 3));
//

//creating template
$tpl=new tpl;
//header
$tpl->create('header.php', array('title' => $GLOBALS['lang']['global']['site_title'], 'description' => $GLOBALS['lang']['global']['site_description'], 'keywords' => $GLOBALS['lang']['global']['site_keywords'], 'theme_path'=>$GLOBALS['theme_path'], 'menu_top' => $menu_top));
//body
$tpl->create('body.php', array('theme_path' => $GLOBALS['theme_path'], 'menu_top' => $menu_top, 'menu_left' => $menu_left, 'content' => $content, 'description'=>$lang['admin_forum']));
//footer
$tpl->create('footer.php', array('site_generation_time' => string_template($GLOBALS['lang']['global']['site_generation_time'], array('site_generation_time'=>$site_generation_time, 'queries'=>$db->query_count())), 'theme_path'=>$GLOBALS['theme_path'], 'copyright' => $GLOBALS['lang']['global']['site_copyright'], 'queries'=>$db->query_count()));
//parse
$tpl->parse();
?>
